//
//  ASBaseTabBarController.m
//
//  Created by wFeng on 14-8-12.
//  Copyright (c) 2014年. All rights reserved.
//

#import "ASBaseTabBarController.h"
#import "ASPersonViewController.h"
#import "AchieveMentViewController.h"
#import "ActivityViewController.h"
#import "AskForLeaveViewController.h"



///////#import "UIImage+Extend.h"

//#import "UINavigationController+YRBackGesture.h"

//! lich 7-30版本，去掉通话记录，显示拨号盘，进入界面拨号盘展开
static NSString *TabBarFirstItemName_KeyboardShow = @"键盘展开";
static NSString *TabBarFirstItemName_KeyboardHide = @"键盘收起";
static NSString *TabBarFirstItemName_Keyboard = @"拨号盘";


//#define TabItemWidth 80             //每个Item的宽
#define TabItemHeight 50            //每个item的高
#define TabItemImageWidth 27        //item中图片的宽
#define TabItemImageHeight 27       //item中图片的高
#define TabSideMarginX 26.5
#define TabSideMarginY 4
#define TabSpacing 0

#ifndef RCSCustomTabBar



@interface ASBaseTabBarController ()
{
    ASBaseNavigationController* _personNavi;
    ASBaseNavigationController* _achieveMentNavi;
    ASBaseNavigationController* _activityNavi;
    ASBaseNavigationController* _askForLeaveNavi;
}

@property (nonatomic, strong)UIImageView*           badgeNumImageView;  //标记又数字  如：99+
@property (nonatomic, strong)NSMutableArray*        badgeImageView; //标记无数字，只有红点
@property (nonatomic, strong)ASPersonViewController*	  personVC;       //个人
@property (nonatomic, strong)AchieveMentViewController*   achieveMentVC;  //成果
@property (nonatomic, strong)ActivityViewController*      activityVC;     //活动
@property (nonatomic, strong)AskForLeaveViewController*	  askForLeaveVC;  //请假
@end




@implementation ASBaseTabBarController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
    }
    return self;
}


- (void)viewDidLoad
{
    //注册通知，用于接收改变语言的通知
    //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLocalLanguage) name:@"changeLanguage" object:nil];
    
    [super viewDidLoad];
    self.isAnimationFinished = YES;
//    self.view.clipsToBounds = YES;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)dealloc
{
    [self removeObserver];
}

- (void)loadView
{
    [super loadView];
    
    [UIApplication sharedApplication].statusBarHidden = NO;
    [self addObserver];
    [self addAllNaviController];
    [self reloadImageResource];
    [self addAllImagesPosition];
    [self setAllViewsToTabbar];
}

- (void)addObserver
{
    //id<IRcSCallbackObserverCenter> center = rcsApiGetCallbackObserverCenter();
    //[center addObserver:self withType: UI_SKIN_UPDATE];
}

- (void)removeObserver
{
    //id<IRcSCallbackObserverCenter> center = rcsApiGetCallbackObserverCenter();
    //[center delObserver:self withType:UI_SKIN_UPDATE];
}

//-(void)UICallbackWithType:(RcSLogic2UiCmd)type state:(CmdReqState)state object:(NSDictionary*)param
//{
//    [self reloadImageResource];
//    [self reloadTabBarItemIcon];
//}


//添加tabbar上面所有的navigationController
- (void)addAllNaviController
{
    self.naviArray = [NSMutableArray array];
	
	// 活动
	_activityVC = [[ActivityViewController alloc] init];
	_activityVC.title = @"活动";
	_activityNavi = [[ASBaseNavigationController alloc] initWithRootViewController:_activityVC];
	[_activityNavi setHidesBottomBarWhenPushed:NO];
	[self.naviArray addObject:_activityNavi];
	
    // 请假
    _askForLeaveVC = [[AskForLeaveViewController alloc] init];
    _askForLeaveVC.title = @"请假";
    _askForLeaveNavi = [[ASBaseNavigationController alloc] initWithRootViewController:_askForLeaveVC];
    //[_askForLeaveNavi hiddBarImage];
    [_askForLeaveNavi setHidesBottomBarWhenPushed:NO];
    [self.naviArray addObject:_askForLeaveNavi];
    
    // 成果
	_achieveMentVC = [[AchieveMentViewController alloc] init];
    _achieveMentNavi = [[ASBaseNavigationController alloc] initWithRootViewController:_achieveMentVC];
    [_achieveMentVC setHidesBottomBarWhenPushed:NO];
    _achieveMentVC.strNavTitle = @"成果";
    _achieveMentVC.title = @"成果";
    [self.naviArray addObject:_achieveMentNavi];
    
    // 个人
    _personVC = [[ASPersonViewController alloc] init];
    _personVC.strNavTitle = @"个人";
    _personVC.title = @"个人";
    _personNavi = [[ASBaseNavigationController alloc] initWithRootViewController:_personVC];
    [_personNavi setHidesBottomBarWhenPushed:NO];
    [self.naviArray addObject:_personNavi];
    
    self.viewControllers = self.naviArray;
}

//设置视图控件
- (void)setAllViewsToTabbar
{
    //初始化tabbarcontroller控件
    self.viewControllers = self.naviArray;
    //self.tabBar.clipsToBounds = YES;
    
    //设置tabbarItem文字颜色和位置
    [[UITabBarItem appearance] setTitleTextAttributes:
           [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0/255.0 green:136.0/255.0 blue:76.0/255.0 alpha:1.0],
                                                      NSForegroundColorAttributeName,
                                                      [UIFont fontWithName:@"STHeitiSC-Medium" size:10],
                                                      NSFontAttributeName, nil]
                                             forState:UIControlStateSelected];
    
//    [[UITabBarItem appearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[RCSFontManage tintColor:RCSTabBarTitleFont], UITextAttributeTextColor,
//                                                      [RCSFontManage fontWithName:RCSTabBarTitleFont], UITextAttributeFont,
//                                                      nil] forState:UIControlStateNormal];
    
    [[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -3)];
    //设置tabbar的items图表
    for (int i = 0; i < [self.itemBgImageViewArray count]; i++)
    {
        UIImageView *itemBg  = [self.itemBgImageViewArray objectAtIndex:i];
        itemBg.image = [self.unSelectedImageArray objectAtIndex:i];
        [self.tabBar addSubview:itemBg];
    }
    
    //设置小红点
    for (int i = 0; i < [self.badgeImageView count]; i++)
    {
        UIImageView* badge = [self.badgeImageView objectAtIndex:i];
        [self.tabBar addSubview:badge];
        [self.tabBar bringSubviewToFront:badge];
    }
    
    self.selectedIndex = 0;
}

/**
 *  加载图片资源
 */
- (void)reloadImageResource
{
    self.tabBar.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - TabItemHeight, [UIScreen mainScreen].bounds.size.width, TabItemHeight);
//    self.tabBar.selectionIndicatorImage = [UIImage createImageWithColor:[UIColor clearColor] andSize:CGSizeMake(320, 64)];

//    self.tabBar.clipsToBounds = YES;
    //[self.tabBar setBackgroundImage:[UIImage imageNamed:@"commom_tabbar"]];//
    [self.tabBar setBackgroundColor:RGB(244, 245, 246)];
    if (SYSTEM_VERSION >= 6.0)
    {
        [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
    }
    //未选中的图标
    NSMutableArray *aunSelectedImageArray = [[NSMutableArray alloc] initWithObjects:
                                             [UIImage imageNamed:@"ic_activity_normal"],
											 [UIImage imageNamed:@"ic_call_normal"],
                                             [UIImage imageNamed:@"ic_fruit_normal"],
                                             [UIImage imageNamed:@"ic_personal_nomal"],
                                             nil];
    self.unSelectedImageArray = aunSelectedImageArray;
    
    //选中的图片
    NSMutableArray *aselectedImageArray = [[NSMutableArray alloc] initWithObjects:
										   [UIImage imageNamed:@"ic_activity_activited"],
                                           [UIImage imageNamed:@"ic_call_activited"],
                                           [UIImage imageNamed:@"ic_fruit_activited"],
                                           [UIImage imageNamed:@"ic_personal_activited"],
                                           nil];
    self.selectedImageArray = aselectedImageArray;
}

/**
 *  重新加载item的图片
 */
- (void)reloadTabBarItemIcon
{
    for (int i = 0; i < [self.itemBgImageViewArray count]; i++)
    {
        UIImageView *itemBg  = [self.itemBgImageViewArray objectAtIndex:i];
        itemBg.image = [self.unSelectedImageArray objectAtIndex:i];
    }
    //将本次的选中效果显示
    UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:self.lastSelectedIndex];
    selectedImageView.image = [self.selectedImageArray objectAtIndex:self.lastSelectedIndex];
}

- (void)addAllImagesPosition
{
    self.itemBgImageViewArray = [NSMutableArray array];
    self.badgeImageView = [NSMutableArray array];
    [self itemLayoutPosition];
}

//计算item的坐标
- (void)itemLayoutPosition
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    int itemCount = [self.naviArray count];
    float width = screenRect.size.width / itemCount;
    float tabMarginx = (width - TabItemImageWidth) * 0.5;
    //设置tabbar的items图标
    if (self.itemBgImageViewArray && self.itemBgImageViewArray.count)
    {
        [self.itemBgImageViewArray removeAllObjects];
    }
    
    for (int i = 0; i < [self.naviArray count]; i++)
    {
        UIImageView *itemBg  = [[UIImageView alloc] initWithFrame:CGRectMake(tabMarginx+width * i, TabSideMarginY, TabItemImageWidth, TabItemImageHeight)];
        itemBg.contentMode = UIViewContentModeScaleAspectFit;
        [self.itemBgImageViewArray addObject:itemBg];
    }
    
//设置小红点
    for (int i = 0; i < [self.naviArray count]; i++)
    {
        UIImageView* badgeView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"msg_tabbar_tips_new"]];
        badgeView.frame = CGRectMake(TabItemImageWidth+tabMarginx+width*i, 6, 6, 6);
        badgeView.hidden = YES;
        [self.badgeImageView addObject:badgeView];
    }
}

#pragma mark - View lifecycle

//设置上次的选中
- (void)setLastSelectedIndex:(int)lastSelectedIndex
{
    if (_lastSelectedIndex != lastSelectedIndex)
    {
        //将上次的选中效果取消
        UIImageView *lastSelectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:_lastSelectedIndex];
//        if (_lastSelectedIndex == 0)
//        {
//            lastSelectedImageView.image = [self.unSelectedImageArray lastObject];
//        }
//        else
//        {
            lastSelectedImageView.image = [self.unSelectedImageArray objectAtIndex:_lastSelectedIndex];
//        }
        _lastSelectedIndex = lastSelectedIndex;
    }
}

- (void)setCallRecordKeyShowTag:(int)callRecordKeyShowTag
{
    if (_callRecordKeyShowTag == 0)
    {
        return;
    }
    if (0 == callRecordKeyShowTag)
    {
        _callRecordKeyShowTag = 1;
        UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex: self.selectedIndex];
        selectedImageView.image = [UIImage imageNamed: @"call_tabbar_pressed_receipt"];
    }
}

//设置选中
- (void)setSelectedIndex:(NSUInteger)selectedIndex
{
    [super setSelectedIndex:selectedIndex];
    [self.currNavi popToRootViewControllerAnimated:NO];
    self.currNavi = [self.naviArray objectAtIndex:selectedIndex];
    //将上次的选中效果取消
    self.lastSelectedIndex = selectedIndex;
    
    if (0 == selectedIndex)
    {
        if (0 == _callRecordKeyShowTag)
        {
//            _callRecordKeyShowTag = 0;
            UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:selectedIndex];
            selectedImageView.image = [UIImage imageNamed: @"ic_activity_activited"];
        }
        else if (1 == _callRecordKeyShowTag)
        {
            //_callRecordKeyShowTag = 1;
			UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:selectedIndex];
			selectedImageView.image = [UIImage imageNamed: @"ic_call_activited"];
//            [[NSNotificationCenter defaultCenter] postNotificationName:TelephoneDialViewDisplayChangedNotification object:[NSNumber numberWithBool:NO]];
        }
        else if (2 == _callRecordKeyShowTag)
        {
            //_callRecordKeyShowTag = 2;
            UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:selectedIndex];
            selectedImageView.image = [UIImage imageNamed: @"ic_fruit_activited"];
//            [[NSNotificationCenter defaultCenter] postNotificationName:TelephoneDialViewDisplayChangedNotification object:[NSNumber numberWithBool:YES]];
        }
        else if (3 == _callRecordKeyShowTag)
        {
            //_callRecordKeyShowTag = 3;
            UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:selectedIndex];
            selectedImageView.image = [UIImage imageNamed: @"c_personal_activited"];
            //            [[NSNotificationCenter defaultCenter] postNotificationName:TelephoneDialViewDisplayChangedNotification object:[NSNumber numberWithBool:YES]];
        }
    }
    else
    {
        _callRecordKeyShowTag = 0;
        //将本次的选中效果显示
        UIImageView *selectedImageView = (UIImageView *)[self.itemBgImageViewArray objectAtIndex:selectedIndex];
        selectedImageView.image = [self.selectedImageArray objectAtIndex:selectedIndex];
    }
}

//显示红点, -1标示是红点显示 0标示不显示， >0 标示显示的是带有数字的标记
//显示红点,count传0时，不显示,
- (BOOL)setBadgeValue:(int)count withTabbarType:(KTabbarItemType)barItemType
{
    if(barItemType >= [self.badgeImageView count])
        return NO;
    
    if(count == 0)
    {
        UIImageView* badge = [self.badgeImageView objectAtIndex:barItemType];
        badge.hidden = YES;
    }
    else
    {
        UIImageView* badge = [self.badgeImageView objectAtIndex:barItemType];
        badge.hidden = NO;
    }
    
    return YES;
}

-(void)setBadetValueWithNum:(NSInteger)numbers withTabbarType:(KTabbarItemType)barItemType
{
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    int itemCount = [self.naviArray count];
    float width = screenRect.size.width / itemCount;
    float tabMarginx = (width - TabItemImageWidth) * 0.5;
    CGRect rect = CGRectMake(TabItemImageWidth+tabMarginx+width*barItemType, 6, 6, 6);
    
    if (self.badgeNumImageView)
    {
        [self.badgeNumImageView removeFromSuperview];
        self.badgeNumImageView = nil;
    }
    
    if (numbers > 0)
    {
		self.badgeNumImageView = [self drawBadgeView:numbers badgerect:rect];
		UIView* editView = [self.tabBar viewWithTag:1010]; // 消息模块 - 全局搜索框
        UIView *recordEditView = [self.tabBar viewWithTag:recordTabEditViewTag];
        BOOL editStatus = NO;
		if (editView != nil )
        {
            editStatus = YES;
			[self.tabBar insertSubview:self.badgeNumImageView belowSubview:editView];//全局搜索框位于顶部
		}
        if (recordEditView != nil)
        {
            editStatus = YES;
            [self.tabBar insertSubview:self.badgeNumImageView belowSubview:recordEditView];
        }
        if (!editStatus)
        {
            [self.tabBar addSubview:self.badgeNumImageView];
            [self.tabBar bringSubviewToFront:self.badgeNumImageView];
        }
    }
}

//特殊处理Item
- (void)selectItmeSpecial:(int)selectedIndex
{
    if (self.lastSelectedIndex == selectedIndex)
    {
        if (self.keyboardShow)
        {
            //隐藏键盘
            self.keyboardShow = NO;
        }
        else
        {
            //显示键盘
            self.keyboardShow = YES;
        }
    }
}

- (UIImageView *)drawBadgeView:(NSUInteger)count badgerect:(CGRect)badgerect
{
    UIImageView *imageView = nil;
	UIImage *image = [UIImage imageNamed:@"message_bubble"];
    CGFloat top = 8;
    CGFloat bottom = 8;
    CGFloat left = 8.5;
    CGFloat right = 8.5;
    UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
    //伸缩后重新赋值
    image = [image resizableImageWithCapInsets:insets];
    UILabel *lable = [[UILabel alloc] init];
    NSString *countStr_ = nil;
    if (count > 99)
    {
        countStr_ = @"99+";
    }
    else
    {
        countStr_ = [NSString stringWithFormat:@"%ld",count];
    }
    CGSize size = [countStr_ sizeWithFont:[UIFont systemFontOfSize:10.0]];
    CGFloat width_ = size.width + 8.0;
    if (width_ < 16.0)
    {
        width_ = 16.0;
    }
    CGRect imageViewFream = CGRectMake(badgerect.origin.x,badgerect.origin.y,width_,16.0);;
    imageView = [[UIImageView alloc] initWithImage:image];
    imageView.backgroundColor = [UIColor clearColor];
    imageView.frame = imageViewFream;
    lable.frame = CGRectMake(0, 0, imageViewFream.size.width, imageViewFream.size.height);
    lable.text = countStr_;
    lable.font = [UIFont systemFontOfSize:10.0];
    lable.textColor = [UIColor whiteColor];
    lable.backgroundColor = [UIColor clearColor];
    lable.textAlignment = NSTextAlignmentCenter;
    [imageView addSubview:lable];
    return imageView;
}

#pragma mark - UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    NSInteger tmpIndex = [tabBar.items indexOfObject:item];
    if (0 == tmpIndex)
    {
        if (!self.isAnimationFinished)
        {
            return;
        }
    }
    else
    {
        self.isAnimationFinished = YES;
    }
    self.selectedIndex = tmpIndex;
    
    [item setFinishedSelectedImage:nil withFinishedUnselectedImage:nil];
}

#pragma mark-旋屏的方法设置

//返回该controller支持的设备状态
- (NSUInteger)supportedInterfaceOrientations
{
    //返回顶层视图支持的旋转方向
    return UIInterfaceOrientationMaskPortrait;//self.currNavi.topViewController.supportedInterfaceOrientations;
}

//设置该controller是否可自动旋屏
- (BOOL)shouldAutorotate
{
    return NO;//self.currNavi.topViewController.shouldAutorotate;
}


- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_AVAILABLE_IOS(3_0)//当发送旋屏事件后，就会掉用该方法
{
    
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    //横屏
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
    }
    else
    {
        //竖屏 UIInterfaceOrientationPortrait
    }
}


/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

#else

@interface ASBaseTabBarController ()
{
    RCSBaseNavigationController* _newCallNavi;
    RCSBaseNavigationController* _addressBookNavi;
    RCSBaseNavigationController* _newMessageNavi;
    RCSBaseNavigationController* _mySelfProfileNavi;
}

- (void)setupForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;

@end

@implementation ASBaseTabBarController

- (void)loadView
{
    [super loadView];
    
    [UIApplication sharedApplication].statusBarHidden = NO;
    
    [self addAllNaviController];
//  [self addAllImagesResource];
//  [self setAllViewsToTabbar];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    _callRecordKeyShowTag = 0;
}

//添加tabbar上面所有的navigationController
- (void)addAllNaviController
{
    self.naviArray = [NSMutableArray array];
    
    //新通话
//    RCSNewCallViewController *newCallVC = [[RCSNewCallViewController alloc] init];
//    newCallVC.title = TabBarFirstItemName_KeyboardShow;
//    _newCallNavi = [[RCSBaseNavigationController alloc] initWithRootViewController:newCallVC];
//    _newCallNavi.rcs_tabBarItem = [RCSTabBarItem itemWithTitle:TabBarFirstItemName_KeyboardShow image:[RCSFontManage imageNamed:@"chyh_icon_dhyc_pressed"]];
//    [_newCallNavi setHidesBottomBarWhenPushed:NO];
//    [self.naviArray addObject:_newCallNavi];
//    
//    //通讯录
//    RCSAddressBookViewController* addressBookVC = [[RCSAddressBookViewController alloc] init];
//    addressBookVC.title = @"通讯录";
//    _addressBookNavi = [[RCSBaseNavigationController alloc] initWithRootViewController:addressBookVC];
//    _addressBookNavi.rcs_tabBarItem = [RCSTabBarItem itemWithTitle:@"通话记录" image:[RCSFontManage imageNamed:@"chyh_icon_dhyc_pressed"]];
//
//    [_addressBookNavi setHidesBottomBarWhenPushed:NO];
//    [self.naviArray addObject:_addressBookNavi];
//    
//    //新消息
//    RCSMsgBoxViewController* msgBoxVC = [[RCSMsgBoxViewController alloc] init];
//    msgBoxVC.title = @"消息";
//    _newMessageNavi = [[RCSBaseNavigationController alloc] initWithRootViewController:msgBoxVC];
//    _newMessageNavi.rcs_tabBarItem = [RCSTabBarItem itemWithTitle:@"通话记录" image:[RCSFontManage imageNamed:@"chyh_icon_dhyc_pressed"]];
//
//    [_newMessageNavi setHidesBottomBarWhenPushed:YES];
//    [self.naviArray addObject:_newMessageNavi];
//    
//    //myProfile
//    RCSProfileVC* myProfileVC = [[RCSProfileVC alloc] init];
//    //myProfileVC.title = @"我";//FTLocalizedString(@"MainMoreViewControllerTitle");
//    _mySelfProfileNavi = [[RCSBaseNavigationController alloc] initWithRootViewController:myProfileVC];
//    _mySelfProfileNavi.rcs_tabBarItem = [RCSTabBarItem itemWithTitle:@"通话记录" image:[RCSFontManage imageNamed:@"chyh_icon_dhyc_pressed"]];
//
//    [_mySelfProfileNavi setHidesBottomBarWhenPushed:NO];
//    [self.naviArray addObject:_mySelfProfileNavi];
    
    self.viewControllers = self.naviArray;
    
}

- (id)initWithDelegate:(id<ASTabBarControllerDelegate>)delegate
{
    self = [super initWithDelegate:delegate];
    if (self)
    {
        self.animation = ASTabBarControllerAnimationNone;
        self.tabBar.tintColor = [UIColor colorWithRed:143.f/255.f green:39.f/255.f blue:47.f/255.f alpha:1.f];
        self.tabBar.itemPadding = 10.f;
        [self setupForInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation];
    }
    
    return self;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    
    [self setupForInterfaceOrientation:toInterfaceOrientation];
}

#pragma mark - Private

- (void)setupForInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
    {
        self.tabBarPosition = RCSTabBarPositionBottom;
        self.tabBar.showsItemHighlight = NO;
        self.tabBar.layoutStrategy = RCSTabBarLayoutStrategyCentered;
    }
    else
    {
        self.tabBarPosition = RCSTabBarPositionLeft;
        self.tabBar.showsItemHighlight = YES;
        self.tabBar.layoutStrategy = RCSTabBarLayoutStrategyStrungTogether;
    }
}



@end

#endif
